package ferp.android.dialogs;

import android.content.Context;
import ferp.android.R;
import ferp.android.managers.CloudManager;

/**
 * User: igorgok
 * Date: 15/07/2014 11:04
 */
public class CloudActionsDialog extends ObjectRadioListViewDialog<CloudActionsDialog.Action>
{
  public enum Action {LOGON, LOAD_DATA, SWITCH_ACCOUNT, LOGOUT}

  public interface Listener extends ObjectRadioListViewDialog.Listener<CloudActionsDialog.Action> {}

  public CloudActionsDialog(Context context, Listener listener)
  {
    super(context, listener, R.string.dialog_cloud_actions_title);
  }

  public void prepare(CloudManager cm)
  {
    clear();

    if (cm.isLoggedIn())
    {
      add(R.string.dialog_cloud_actions_option_load_data, Action.LOAD_DATA, true);
      add(R.string.dialog_cloud_actions_option_switch_account, Action.SWITCH_ACCOUNT, true);
      add(R.string.dialog_cloud_actions_option_logout, Action.LOGOUT, cm.canLogout());
    }
    else
    {
      add(R.string.dialog_cloud_actions_option_logon, Action.LOGON, true);
      add(R.string.dialog_cloud_actions_option_load_data, Action.LOAD_DATA, false);
    }

    ld.invalidate();
  }
}
